package contract

import (
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/ethclient"
	"go-chain-api/contract/evmAbi"
	"log"
)

func GetTokenByTokenAddress(client *ethclient.Client, address common.Address) ([]interface{}, []interface{}, error) {
	token0, err := CallContractMethod(client, address, evmAbi.UNISWAP_V2_PAIR_ABI, "token0")
	if err != nil {
		log.Printf("failed to get token0: %v", err)
		return nil, nil, err
	}
	token1, err := CallContractMethod(client, address, evmAbi.UNISWAP_V2_PAIR_ABI, "token1")
	if err != nil {
		log.Printf("failed to get token1: %v", err)
		return nil, nil, err
	}

	return token0, token1, nil
}
